﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markup="clr-namespace:Elysium.Markup"
                    xmlns:params="clr-namespace:Elysium.Parameters"
                    xmlns:controls="clr-namespace:Elysium.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/Scrolls/ScrollBar.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/Themes/Scrolls/ScrollViewer.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type controls:Submenu}" TargetType="{x:Type controls:Submenu}">
        <Setter Property="Background" Value="{markup:ThemeResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{markup:ThemeResource HighlightBrush}"/>
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Background, Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush, Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderThickness, Mode=OneWay}"/>
        <Setter Property="Foreground" Value="{markup:ThemeResource ForegroundBrush}"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
        <Setter Property="params:General.ShadowBrush" Value="{markup:ThemeResource BackgroundContrastBrush}"/>
        <Setter Property="Grid.IsSharedSizeScope" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalOnly"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:Submenu}">
                    <Border x:Name="LayoutRoot"
                            Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}"
                            TextBlock.FontSize="{TemplateBinding FontSize}"
                            TextBlock.FontStretch="{TemplateBinding FontStretch}"
                            TextBlock.FontStyle="{TemplateBinding FontStyle}"
                            TextBlock.FontWeight="{TemplateBinding FontWeight}"
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding ElementName=LayoutRoot, Path=Tag}" Value="True">
                            <Setter TargetName="LayoutRoot" Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:Submenu}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}"
                                                      BlurRadius="4" ShadowDepth="2"
                                                      Direction="315"
                                                      Opacity="0.3"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{markup:ThemeResource TransparentBrush}"/>
                            <Setter TargetName="LayoutRoot" Property="Padding" Value="0,0,6,6"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal"/>
            </DataTrigger>
        </Style.Triggers>        
    </Style>

</ResourceDictionary>